﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleData.ObjectModel.Design;
using DataAccess.SqlClient;
using SimpleData.ObjectModel;

namespace SimpleData
{
	public static class FieldTypeDataGenExtensions
	{

		public static DataGenEntityBuilder<FieldTypeDescriptor> FieldType( this DGen dgen )
		{
			return dgen.FieldType( "fieldType" );
		}

		public static DataGenEntityBuilder<FieldTypeDescriptor> FieldType( this DGen dgen, string name )
		{
			var fieldType = new DataGenEntityBuilder<FieldTypeDescriptor>( dgen, new DataObjectContext(), new TestFieldTypeDescriptor( new FieldTypeName( dgen.GetRandomName( name ) ) ) );

			fieldType.Entity.DisplayName = dgen.GetRandomName( "Type -" );
			//fieldType.Entity.Rule = new FieldTypeRule( new RuleName( dgen.GetRandomName( "Rule -" ) ) );
			return fieldType;
		}

		//public static DataGenEntityBuilder<FieldTypeDescriptor> UsingRule( this DataGenEntityBuilder<FieldTypeDescriptor> builder, IRuleBuilder ruleBuilder )
		//{
		//    return builder.UsingRule( ruleBuilder, null );
		//}

		//public static DataGenEntityBuilder<FieldTypeDescriptor> UsingRule( this DataGenEntityBuilder<FieldTypeDescriptor> builder, IRuleBuilder ruleBuilder, Action<FieldTypeRule> update )
		//{
		//    var rule = new FieldTypeRule( new RuleName( builder.DGen.GetRandomName( "rule" ) ) );

		//    rule.ToolTipText = builder.DGen.GetRandomName( "Tip - " );
		//    rule.ErrorMessageFormat = builder.DGen.GetRandomName( "ErrorMsg - " );

		//    if ( update != null )
		//        update( rule );

		//    builder.Entity.Rule = rule;
		//    return builder;
		//}
	}


	public class TestFieldTypeDescriptor : FieldTypeDescriptor
	{

		public TestFieldTypeDescriptor( FieldTypeName name )
			: base( name )
		{ }

		public override IFieldTypeConverter CreateConverter( FieldDescriptor field )
		{
			throw new NotImplementedException();
		}

		public override IRuleBuilder CreateRuleBuilder( Rule data )
		{
			throw new NotImplementedException();
		}
	}
}
